<?php

namespace Lib\MySlim;

use Lib\MySlim\Middleware\Configurator;

class Slim extends \SlimController\Slim
{
    public function __construct(array $userSettings = array())
    {
        parent::__construct($userSettings);
        
        $this->add(new Configurator());
    }
    
    public function cfg($target, $attrName, $default = null)
    {
        $app = \Slim\Slim::getInstance();
        $cfgs = $app->config('cfgs');
        // 如果没有读到远程配置
        $cfgs[$target][$attrName] = $default;
        $app->config('cfgs', $cfgs);
        return "$target - $attrName - $default";
    }
}
